<script type="text/javascript">
	var form_url = '/scheduler/job/createScheduleJob' ;
	var jobClassDict ;
	$(function() {
		
		jobClassDict = $('#jobClassDict').combobox({
			url: '/scheduler/classDict/combobox', method: 'GET',
			valueField: 'id', textField: 'dictName', 
			onSelect: function(record){
				$('#jobName').textbox('setValue', record.dictName) ;
				$('#jobGroup').textbox('setValue', record.jobGroup) ;
				$('#className').textbox('setValue', record.className) ;
				$('#beanName').textbox('setValue', record.beanName) ;
				$('#methodName').textbox('setValue', record.methodName) ;
				$('#params').textbox('setValue', record.params) ;
				$('#remarks').textbox('setValue', record.remarks) ;
			}
		});
		
		if(null != "" && "${jobId!}" != "") {
			form_url = '/scheduler/job/rescheduleJob' ;
			$.get('/scheduler/job/get/${jobId!}', function(result) {
				try {
					$('#form').form('load', result);
					jobClassDict.combobox('setValue', result.jobName);
				} catch(e) {
					$.easyui.loaded(); console.error(e) ;
				}
			}, 'JSON').complete(function(){$.easyui.loaded();});
		}		
	});
	
	function submitForm() {
		var checkform = $('#form').form('validate');
		if(checkform) {
			$.easyui.loading();
			$.post(form_url, MM.getData('#form'), function(result) {
				try {
					if(result.code == 200) {
						$obj.reload();$window.window('close');alertify.success(result.message);
					} else {
						$.messager.alert('提示信息', result.message, 'warning') ;
					}
				} catch(e) {
					$.easyui.loaded(); console.error(e) ;
				}
			}, 'JSON').complete(function(){$.easyui.loaded();});
		}
	}
</script>

<div class="easyui-panel form-panel" data-options="border: false, fit: true">
	<form id="form" method="post">
		<input type="hidden" name="jobId" value="${jobId!}">
		<table class="table-form">
			<tr>
				<th style="width:120px;">定时作业：</th>
				<td>
					<select id="jobClassDict" style="width:180px;" data-options="editable: false, panelHeight:'auto'">
		            </select>
				</td>
			</tr>
			<tr>
				<th style="width:120px;">定时作业：</th>
				<td>
					<select class="easyui-combobox" name="status" style="width:180px;" data-options="editable: false, panelHeight:'auto', disable: true">
		                <option value="0">正常</option>
		                <option value="1">暂停</option>
		            </select>
				</td>
			</tr>
			<tr>
				<th>Cron表达式：</th>
				<td><input class="easyui-textbox" name="cronExpression" value="0/5 * * * * ?" style="width:300px" data-options="required:true,validateOnCreate:false,validateOnBlur:true"></td>
			</tr>
			<tr>
				<th>作业名称：</th>
				<td><input id="jobName" class="easyui-textbox" name="jobName" style="width:300px" data-options="required:true,validateOnCreate:false,validateOnBlur:true"></td>
			</tr>
			<tr>
				<th>作业分组名：</th>
				<td><input id="jobGroup" class="easyui-textbox" name="jobGroup" style="width:300px" data-options="required:true,validateOnCreate:false,validateOnBlur:true"></td>
			</tr>
			<tr>
				<th>作业全类名：</th>
				<td><input id="className" class="easyui-textbox" name="className" style="width:300px" data-options="required:true,validateOnCreate:false,validateOnBlur:true"></td>
			</tr>
			<tr>
				<th>Bean实例名称：</th>
				<td><input id="beanName" class="easyui-textbox" name="beanName" style="width:300px" data-options="required:true,validateOnCreate:false,validateOnBlur:true"></td>
			</tr>
			<tr>
				<th>作业方法名：</th>
				<td><input id="methodName" class="easyui-textbox" name="methodName" style="width:300px" data-options="required:true,validateOnCreate:false,validateOnBlur:true"></td>
			</tr>
			<tr>
				<th>参数：</th>
				<td colspan="3"><input id="params" class="easyui-textbox" name="params" style="width:100%;height:60px" data-options="multiline:true"></td>
			</tr>
			<tr>
				<th>描述信息：</th>
				<td colspan="3"><input id="remarks" class="easyui-textbox" name="remarks" style="width:100%;height:60px" data-options="multiline:true"></td>
			</tr>
		</table>
	</form>
</div>

<div class="submit-toolbar" id="footer"  style="border-bottom: 0;border-left: 0;border-right: 0;">
	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="submitForm()" style="width:80px">提交</a>
	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="MM.closeCurrentWindow()" style="width:80px">关闭</a>
</div>
